package testGuava.example.testApach;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;

/**
 * @ClassName : org.example.testApach.IOTest
 * @Description : 类描述
 * Created by cyd on 2021-09-15 14:18:41
 */
public class IOTest {
    @Test
    public void testFileNameUtils() {
        String path = "D:\\WorkSpace\\test-guava\\src\\main\\resources\\123.txt";
        System.out.println(FilenameUtils.getExtension(path));
        System.out.println(FilenameUtils.getBaseName(path));
    }

    @Test
    public void testFileUtils() throws IOException {
        String path = "D:\\WorkSpace\\test-guava\\src\\main\\resources\\123.txt";
        System.out.println(FileUtils.readFileToString(new File(path), String.valueOf(StandardCharsets.UTF_8)));
        List<String> list = FileUtils.readLines(new File(path), String.valueOf(StandardCharsets.UTF_8));
        System.out.println(list.size());
    }
}
